//
//  MBProgress-fast.swift
//  Aiwei
//
//  Created by zhu xietong on 2017/11/22.
//  Copyright © 2017年 zhu xietong. All rights reserved.
//

import Foundation
import MBProgressHUD


extension MBProgressHUD{
    public func __show(_ title:String?=nil,detail:String?=nil,image:UIImage?=nil,minSize:CGSize?=nil) {
        self.customView = UIImageView(image: image)
        if let size = minSize
        {
            self.minSize = size
        }
        self.mode = .customView
        var delay:Double = 1.3
        if let s1 = title
        {
            if s1.len > 14
            {
                delay = delay + 1.0
            }
        }
        if let s1 = detail
        {
            if s1.len > 20
            {
                delay = delay + 1.5
            }
        }
        
        self.label.text = title
        self.detailsLabel.text = detail
        
        weak var wself = self
        
        co_delay(delay: delay) {
            wself?.superview?.isUserInteractionEnabled = true
            wself?.hide(animated: true)
        }
    }

    public func __loading(_ text:String?=nil,detail:String?=nil,minSize:CGSize?=nil) {
        if let size = minSize
        {
            self.minSize = size
        }
        self.mode = .customView
        self.label.text = text
        self.detailsLabel.text = detail

    }

    
}
